package com.kawa.kemanage.mapper;

import com.kawa.kemanage.entity.NewsDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface NewsMapper {

    /**
     * 根据类型，文章标题，发布时间,查询所有新闻
     * @return
     */

   List<NewsDetail> findAllNews(@Param("categoryId") Integer categoryId,
                                @Param("title") String title,
                                @Param("createDate") Date createDate,
                                @Param("modifyDate") Date modifyDate);





    /**
     * 根据id查询新闻
     * @param id
     * @return
     */
    @Select("SELECT id, title, category, content, cover_image AS coverImage, " +
            "publish_time AS publishTime, status, author " +
            "FROM news_detail WHERE id = #{id}")
    NewsDetail getNewsById(@Param("id") Long id);



    /**
     * 新增新闻
     * @param newsDetail
     * @return
     */
    int addNews(NewsDetail newsDetail);



    /**
     * 根据id修改新闻
     * @param news
     * @return
     */
    int updateNewsById(NewsDetail news);





    /**
     * 根据id删除新闻
     * @param id
     * @return
     *
     * */
    int delNewsById(int id);

}
